package com.isunland.managesystem.common;

import com.android.volley.VolleyError;
import com.isunland.managesystem.base.BaseOriginal;
import org.json.JSONException;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/5/23 14:45
 */

@SuppressWarnings("unused") public class SimpleResponse extends VolleyResponse {
  private static final int ERROR = 3;
  private int result;

  public int getResult() {
    return result;
  }

  public boolean isSuccess() {
    return result == BaseOriginal.SUCCESS;
  }

  private void setResult(int result) {
    this.result = result;
  }

  @Override public void onVolleyError(VolleyError arg0) {
    setResult(ERROR);
  }

  @Override public void onVolleyResponse(String json) throws JSONException {
    setResult(inflate(json).getResult());
  }
}
